package com.kc.gb.device.plugins.slant.controller;

import com.kc.gb.base.dto.Result;
import com.kc.gb.device.common.properties.DeviceProperties;
import com.kc.gb.device.plugins.slant.service.SlantHardwareService;
import com.kc.gb.feign.slant.support.SlantCommand;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

@RestController
@RequestMapping("/device/slant")
public class SlantHardwareController {

    @Resource
    DeviceProperties iDeviceProperties;

    @Resource
    SlantHardwareService deviceSlantService;

    @PostMapping("/commands")
    Result<?> commands(@RequestBody List<SlantCommand> commands) {
        // 硬件设备直接调用默认使用模拟器模式
        AtomicBoolean DEBUG_MODE = new AtomicBoolean(true);
        deviceSlantService.consumeCommands(commands,DEBUG_MODE.get());
        return Result.success();
    }
}
